/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import type.VendorInvoiceStatus;

/**
 *
 * @author wei
 */
@Entity(name="VendorInvoice")
public class VendorInvoiceEntity extends DataObjectEntity implements Serializable {
    
    
    private String externalId;
    private double amount;
    private double cost;
    private HashMap scheduleDetail = new HashMap();

    public HashMap getScheduleDetail() {
        return scheduleDetail;
    }

    public void setScheduleDetail(HashMap scheduleDetail) {
        this.scheduleDetail = scheduleDetail;
    }
    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }
    public double getTaxAmount() {
        return taxAmount;
    }

    public void setTaxAmount(double taxAmount) {
        this.taxAmount = taxAmount;
    }
  private double taxAmount;
     @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateReceived;

    public Date getDateReceived() {
        return dateReceived;
    }

    public void setDateReceived(Date dateReceived) {
        this.dateReceived = dateReceived;
    }
   
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dueDate;
   
    private VendorInvoiceStatus status;
    
    @ManyToOne
    private RawMaterialPurchaseOrderEntity rawMaterialPurchaseOrder;

    public VendorInvoiceEntity() {
        super();
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }



    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public String getExternalId() {
        return externalId;
    }

    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }


    public RawMaterialPurchaseOrderEntity getRawMaterialPurchaseOrder() {
        return rawMaterialPurchaseOrder;
    }

    public void setRawMaterialPurchaseOrder(RawMaterialPurchaseOrderEntity rawMaterialPurchaseOrder) {
        this.rawMaterialPurchaseOrder = rawMaterialPurchaseOrder;
    }

    public VendorInvoiceStatus getStatus() {
        return status;
    }

    public void setStatus(VendorInvoiceStatus status) {
        this.status = status;
    }

    @Override
    public String childToString() {
        return "VendorInvoiceEntity{" + "externalId=" + externalId + ", amount=" + amount + ", dueDate=" + dueDate +  ", status=" + status + ", rawMaterialPurchaseOrder=" + rawMaterialPurchaseOrder + '}';
    }
    private boolean temp =false;//a trick to save the Id 

    public boolean isTemp() {
        if(this.getStatus().equals(VendorInvoiceStatus.settled))return false;
        return temp;
    }

    public void setTemp(boolean temp) {
        this.temp = temp;
    }
    
}
